package com.user.seat.controller;

import com.user.seat.domain.*;
import com.user.seat.service.SeatService;
import com.user.seat.service.UserSeatService;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;

/**
 * @author jimmy
 * Date  2022/4/21 14:19
 * @version 1.0
 */
@RestController
public class  UserSeatController{

    private final UserSeatService userSeatService;
    private final SeatService seatService;

    public UserSeatController(UserSeatService userSeatService,
                              SeatService seatService){
         this.userSeatService = userSeatService;
         this.seatService = seatService;
    }

    @CrossOrigin(origins = {"*"})
    @PostMapping("/login")
    public ResultInfo login(@RequestBody SeatUser seatUser){
        return userSeatService.doLogin(seatUser);

    }

    @CrossOrigin(origins = {"*"})
    @PostMapping("/register")
    public ResultInfo register(@RequestBody SeatUser seatUser){
        return userSeatService.doRegister(seatUser);

    }

    @CrossOrigin(origins = {"*"})
    @PutMapping("/reset/nikName")
    public ResultInfo updateNikName(@RequestBody SeatUser seatUser){
        return userSeatService.doUpdateNikName(seatUser);
    }

    @CrossOrigin(origins = {"*"})
    @PostMapping("/set/seats")
    public ResultInfo seatsNumber(@RequestBody SeatNumber seatNumber){
        return seatService.setSeatsNumber(seatNumber);

    }

    @CrossOrigin(origins = {"*"})
    @GetMapping("/seats")
    public ResultInfo seats(){
        return seatService.getSeatsNumber();

    }

    @CrossOrigin(origins = {"*"})
    @PostMapping("/take/seat")
    public ResultInfo takeSeat(@RequestBody SeatStatusInfo seatStatusInfo){
        return seatService.doTakeSeat(seatStatusInfo);

    }

    @CrossOrigin(origins = {"*"})
    @GetMapping("/get/seat")
    public ResultInfo getSeat(){
        return seatService.doGetSeat();
    }

    //刷新重置
    @CrossOrigin(origins = {"*"})
    @PostMapping("/reset/seat")
    public ResultInfo resetSeat(){
        return seatService.doResetSeat();

    }
    //踢人
    @CrossOrigin(origins = {"*"})
    @PutMapping("/out/seat")
    public ResultInfo outSeat(@RequestBody SeatStatus seatStatus){
        return seatService.doOutSeat(seatStatus);
    }



}
